<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('图片')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-image" class="form-control" data-rule="required" size="50" name="row[image]" type="text" value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-image"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-image"></ul>
        </div>
    </div>


    <div class="form-group">
        <label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('产品类型')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
                <option data-type="type" value="场所"  selected >场所</option>
                <option data-type="type" value="商品"  >商品</option>
            </select>
        </div>
    </div>


    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('名称')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" class="form-control" data-rule="required" name="row[name]" type="text" value="">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('价格')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-price" class="form-control" data-rule="required" name="row[price]" type="text" value="">
        </div>
    </div>


    <div id="xuni">

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">{:__('地址')}:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-site" class="form-control" name="row[site]" type="text" value="">
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">{:__('人数')}:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-count" class="form-control" name="row[count]" type="text" value="">
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">{:__('配套')}:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-mating" class="form-control" name="row[mating]" type="text" value="">
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">{:__('开放时间')}:</label>
            <div class="col-xs-12 col-sm-8">
                {:build_radios('row[opening_hours]', ['1'=>__('每周一'), '2'=>__('每周二'), '3'=>__('每周三'), '4'=>__('每周四'), '5'=>__('每周五'), '6'=>__('每周六'), '7'=>__('每周日'), '8'=>__('周一至周日')])}
            </div>
        </div>

    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('说明')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="a-msg" class="form-control editor" data-rule="required" rows="5" name="row[msg]" cols="50"></textarea>
        </div>
    </div>



    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<script src="/assets/img/jquery-3.4.1.min.js"></script>
<script>
    // $('#shiwu').hide();
    $('#xuni').show();

    $(document).on("change", "#c-type", function(){
        let type =  $("#c-type option:selected").val();
        //变更后的回调事件
        //console.log(type);

        if(type == '场所'){
            // $('#shiwu').hide();
            $('#xuni').show();

        }else if(type == '商品'){
            // $('#shiwu').show();
            $('#xuni').hide();
        }

    });
</script>